package com.example.demo.controller;

import com.example.demo.model.TableData;
import com.example.demo.service.TableDataService;
import com.example.demo.service.TableDataServiceFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/api")
public class TableDataController {

    @Autowired
    private TableDataServiceFactory serviceFactory;

    @GetMapping("/table-data")
    public List<TableData> getTableData(@RequestParam String source) {
        TableDataService service = serviceFactory.getService(source);
        return service.getTableData();
    }
}    